#include <jni.h>
#include <string>
#include "2048.h"

extern "C" {

// JNI 方法：初始化游戏表
JNIEXPORT void JNICALL
Java_com_das_a2048help_Game2048_nativeInit(JNIEnv* env, jobject obj) {
    init_tables();
}

// JNI 方法：开始游戏
JNIEXPORT void JNICALL
Java_com_das_a2048help_Game2048_nativePlayGame(JNIEnv* env, jobject obj) {
    play_game(find_best_move);
}

// JNI 方法：查找最佳移动
JNIEXPORT jint JNICALL
Java_com_das_a2048help_Game2048_nativeFindBestMove(JNIEnv* env, jobject obj, jlong board) {
    return find_best_move(static_cast<board_t>(board));
}

}

// Write C++ code here.
//
// Do not forget to dynamically load the C++ library into your application.
//
// For instance,
//
// In MainActivity.java:
//    static {
//       System.loadLibrary("a2048help");
//    }
//
// Or, in MainActivity.kt:
//    companion object {
//      init {
//         System.loadLibrary("a2048help")
//      }
//    }